Fix the 06_block-list_checkremove test. The use of string.find was invalid
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Sat, 26 Nov 2005 01:08:26 +0000 (01:08 +0000)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Sat, 26 Nov 2005 01:08:26 +0000 (01:08 +0000)
(should be testing against -1, not merely using if or if not), one block-list
command was missing, and the block-detach command is asynchronous (to give the
domain time to close down the device) so we need a time.sleep(1) call before
trying xm block-list.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/xm-test/tests/block-list/06_block-list_checkremove_pos.py

index 14956fc5c43c6cf427a863171b10795797e4098c..ccaf0d72cc8b4ba3983f09e07fc580b0d323db69 100644 (file)
@@ -30,7 +30,7 @@ if s != 0:
 s, o = traceCommand("xm block-list %s" % domain.getName())
 if s != 0:
     FAIL("block-list failed")
-if not o.find("769"):
+if o.find("769") == -1:
     FAIL("block-list didn't show the block device I just attached!")
 
 s, o = traceCommand("xm block-attach %s phy:/dev/ram1 hda2 w" % domain.getName())
@@ -40,25 +40,31 @@ if s != 0:
 s, o = traceCommand("xm block-list %s" % domain.getName())
 if s != 0:
     FAIL("block-list failed")
-if not o.find("770"):
+if o.find("770") == -1:
     FAIL("block-list didn't show the other block device I just attached!")
 
 s, o = traceCommand("xm block-detach %s 769" % domain.getName())
 if s != 0:
-    FAIL("block-destroy of hda1 failed")
+    FAIL("block-detach of hda1 failed")
 
+time.sleep(1)
 s, o = traceCommand("xm block-list %s" % domain.getName())
 if s != 0:
     FAIL("block-list failed after detaching a device")
-if o.find("769"):
+if o.find("769") != -1:
     FAIL("hda1 still shown in block-list after detach!")
-if not o.find("770"):
+if o.find("770") == -1:
     FAIL("hda2 not shown after detach of hda1!")
 
 s, o = traceCommand("xm block-detach %s 770" % domain.getName())
+if s != 0:
+    FAIL("block-detach of hda2 failed")
+
+time.sleep(1)
+s, o = traceCommand("xm block-list %s" % domain.getName())
 if s != 0:
     FAIL("block-list failed after detaching another device")
-if o.find("770"):
+if o.find("770") != -1:
     FAIL("hda2 still shown in block-list after detach!")
 if o:
     FAIL("block-list still shows something after all devices detached!")